﻿<?

define('BASEPATH', true);
include('inc/config.php');

if($site['maintenance'] > 0){redirect('maintenance');}
if($_GET['ref'] != ""){setcookie("PlusREF", $db->EscapeString($_GET['ref']), time()+3600);}

if(isset($_POST['logare'])) {
	$name = $db->EscapeString($_POST['login']);
	$pass = $db->EscapeString($_POST['pass']);
	$ltype = ($site['reg_logtype'] == 1 ? '`email`' : '`login`');
	$sql = $db->Query("SELECT id,login,banned,activate FROM `users` WHERE ".$ltype."='".$name."' AND `pass`=MD5('".$pass."')");
	$data = $db->FetchArray($sql);

	if($data['banned'] > 0){
		$errMsg = "ERROR: Your account is banned!";
	}elseif($data['activate'] > 0){
		$errMsg = "ERROR: You need to confirm your email first!";
	}elseif($data['id'] != '') {
		$db->Query("UPDATE `users` SET `online`=NOW() WHERE `login`='".$data['login']."'");
		$_SESSION['EX_login'] = $data['login'];
		redirect('index.php');
	}else{
		$errMsg = "ERROR: Username or password are wrong!";
	}
}
?>
<?
$users = $db->GetNumRows($db->Query("SELECT id FROM `users`"));
$banned = $db->GetNumRows($db->Query("SELECT id FROM `users` WHERE `banned`='1'"));
$google = $db->GetNumRows($db->Query("SELECT id FROM `sites`"));
$facebook = $db->GetNumRows($db->Query("SELECT id FROM `facebook`"));
$twitter = $db->GetNumRows($db->Query("SELECT id FROM `twitter`"));
$surf = $db->GetNumRows($db->Query("SELECT id FROM `surf`"));
$youtube = $db->GetNumRows($db->Query("SELECT id FROM `youtube`"));
$tweet = $db->GetNumRows($db->Query("SELECT id FROM `tweet`"));
$ytsubs = $db->GetNumRows($db->Query("SELECT id FROM `ytsubs`"));
$stumble = $db->GetNumRows($db->Query("SELECT id FROM `stumbleupon`"));

$tot_clicks1 = $db->FetchArray($db->Query("SELECT SUM(visits) AS sum_visits FROM sites"));
$tot_clicks2 = $db->FetchArray($db->Query("SELECT SUM(likes) AS sum_visits FROM facebook"));
$tot_clicks5 = $db->FetchArray($db->Query("SELECT SUM(earned) AS sum_visits FROM twitter"));
$tot_clicks6 = $db->FetchArray($db->Query("SELECT SUM(visits) AS sum_visits FROM surf"));
$tot_clicks9 = $db->FetchArray($db->Query("SELECT SUM(views) AS sum_visits FROM youtube"));
$tot_clicks10 = $db->FetchArray($db->Query("SELECT SUM(visits) AS sum_visits FROM tweet"));
$tot_clicks11 = $db->FetchArray($db->Query("SELECT SUM(earned) AS sum_earned FROM ytsubs"));
$tot_clicks12 = $db->FetchArray($db->Query("SELECT SUM(visits) AS sum_visits FROM stumbleupon"));
$tot_clicks  = $tot_clicks1['sum_visits'] + $tot_clicks2['sum_visits'] + $tot_clicks3['sum_visits'] + $tot_clicks5['sum_visits'] + $tot_clicks6['sum_visits'] + $tot_clicks9['sum_visits'] + $tot_clicks10['sum_visits'] + $tot_clicks11['sum_earned'] + $tot_clicks12['sum_visits'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title><?=$site['site_name']?></title>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  <meta name="description" content="<?=$site['site_description']?>" />
  <meta name="keywords" content="coins, click, earn, facebook, like, google, +1, plus, one, exchange, clicks, twitter, google +1, like exchange, follow exchange, facebook fans" />
  <link rel="stylesheet" href="js/uniform/css/uniform.default.css" type="text/css" media="screen" charset="utf-8" />
  <link rel="stylesheet" href="css/style.css" type="text/css" />
  <link rel="stylesheet" href="css/blue.css" type="text/css" />
    <!--[if IE]>
       <link rel="stylesheet" type="text/css" href="css/ie.css" />
    <![endif]-->
    <!--[if lte IE 8]>
       <link rel="stylesheet" type="text/css" href="css/ltie8.css" />
    <![endif]-->
    <!--[if IE 7]>
       <link rel="stylesheet" type="text/css" href="css/ie7.css" />
    <![endif]-->
	<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
	<script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
	<script type="text/javascript" src="js/jdpicker/jquery.jdpicker.js"></script>
	<script type="text/javascript" src="js/uniform/jquery.uniform.min.js"></script>
	<script type="text/javascript" src="js/jquery.hotkeys.js"></script>
	<script type="text/javascript" src="js/visualize/visualize.jQuery.js"></script>
	<script type="text/javascript" src="js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
	<script type="text/javascript" src="js/jwysiwyg/jquery.wysiwyg.js"></script>
    <script src="js/jquery.tables.js"></script>
	<script type="text/javascript" src="js/main.js"></script>


<script type="text/javascript"> var auto_refresh = setInterval( function() { $('#c_coins').load('system/uCoins.php'); }, 15000); </script></head>	
</head>
<body>
   <h4 class="logo1"> <a href="http://www.liketang.net/" title="Like Tăng Facebook">

                    <img src="img/logos/logo.png"  alt="Like Tăng Facebook" title="Like Tăng Facebook" border="0">

                </a>

            </h4>
			
   <div class="cont soft-blue fixed">
     <div class="menu">
        <div class="menu-wrap">
           <div style="float: left;">
            
			
          </div>

		  <ul id="main_menu">
		   
           </li>
              
			
              <?if(!$is_online){?>
			  <?if($site['reg_status'] == 0){?><li><a href="register.php">Register</a></li><li><a href="faq.php">FAQ</a></li><?}?>
		   </ul>
			  <?}else{?>
			    <li><a href="index.php">Trang chủ</a></li>
			   <li><a href="buy.php">Nạp tiền</a></li>
			  <li><a href="buy.php">Mua Coins</a></li>
			  <li><a href="vip.php">Tài khoản VIP</a></li>
			  <li><a href="daily.php">Thưởng Coins</a></li>
			  <li><a href="coupons.php">Đổi Coupon</a></li>
			  <li><a href="transfer.php">Kiếm tiền</a></li>
			  <li><a href="refer.php">Liên hệ</a></li>
           </ul>
           <?}?>
        </div>
     </div>
     <div class="wrapper">
        <div class="sidebar left">
<?if($is_online){?>

 <div class="block2">
           
            <div class="content">
              <div class="coins" id="currentpoints">You have <font color="#8ac009"><?=$data['coins']?></font> Coins!</div>
            </div>
         </div>
         <div class="block">
            <div class="top">
               <h2>Quản lý tài khoản</h2>
               
            </div>
            <div class="content">
               <ul>
                  <li><a href="addurl.php">Thêm trang mới</a></li>
                  <li><a href="mysites.php">Trang của tôi</a></a></li>
				  <li><a href="twitterconfig.php">Tài khoản Twitter</a></a></li>
				  <li><a href="ysubconfig.php">Tài khoản YouTube</a></a></li>
				  <li><a href="ysubconfig.php">Nạp tiền</a></a></li>
				  <li><a href="ysubconfig.php">Rút tiền mặt</a></a></li>
               </ul>
            </div>
         </div>
		 <div class="block">
            <div class="top">
               <h2>Kiếm Coins</h2>
               
            </div>
            <div class="content">
               <ul>
                  <li><a href="facebook.php">Facebook Likes</a></li>
		  <li><a href="google.php">Google +1</a></li>
                  <li><a href="linkedin.php">Linkedin</a></li>
		  <li><a href="pinterest.php">Pinterest</a></li>
		  <li><a href="tweet.php">Retweet</a></li>
		  <li><a href="soundcloud.php">Soundcloud Followers</a></li>
                  <li><a href="stumbleupon.php">Stumbleupon</a></li>
		  <li><a href="surf.php">Traffic Exchange</a></li>
		  <li><a href="twitter.php">Twitter Followers</a></li>
		  <li><a href="ytlikes.php">Youtube Likes</a></li>
                  <li><a href="youtube.php">Youtube Views</a></li>
		  <li><a href="ytsub.php">Youtube Subscribers</a></li>
               </ul>
            </div>
         </div>
		
<?}else{?>


			
         <div class="block2">
            <div class="top" style="color: #ffffff;">
               <h2>Login</h2>
               
            </div>
            <div class="content text">
                    <form method="post">
					  <fieldset style="border: none;">		 
						 <p>
							 <label><font color="#ffffff"><?=($site['reg_logtype'] == 1 ? 'E-mail' : 'Username')?></font></label><br/>
							 <input class="text big" type="<?=($site['reg_logtype'] == 1 ? 'email' : 'text')?>" value="" name="login" required="required" />
						 </p>
						 <p>
							 <label><font color="#ffffff">Password</font></label> <br/>
							 <input class="password" type="password" value="" name="pass" required="required" />
						 </p>
						  <p>
						  	<input type="submit" class="gbutton" name="logare" value="Login" />
							<a class="bbutton" href="register.php" name="logare">Register</a>
						  </p>
						  <div id="recl"><a href="recover.php">Forgot Password?</a></div>
					  </fieldset>
					  
					</form>
					</div>
         </div>

		 
		
<?}?>
        </div>
<?=($errMsg != '' ? '<b><font color="red">'.$errMsg.'</font></b><br /><br />' : '')?>